


//
//  gyViewController.m
//  tongxiangOASystem
//
//  Created by michael on 2017/4/27.
//  Copyright © 2017年 czd. All rights reserved.
//
#import "CWActionSheet.h"
#import "gyViewController.h"
#import "ZLCGuidePageView.h"
@interface gyViewController ()

@end

@implementation gyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray * imagesarray = [NSArray array];
imagesarray = @[[UIImage imageNamed:@"2、启动页-2（750x1334）.jpg"],[UIImage imageNamed:@"2、启动页-3（750x1334）.jpg"],[UIImage imageNamed:@"2、启动页-1（750x1334）.jpg"]];
_images = imagesarray;
self.view.backgroundColor = [UIColor colorWithHexString:@"f5f5f5"];
self.title = @"关于我们";
[self initview];
}
- (void)initview{
_image = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenWidth-100)/2, 100, 100, 100)];

_image.image = [UIImage imageNamed:@"logo"];
[self.view addSubview:_image];
_label = [[UILabel alloc]initWithFrame:CGRectMake(40, _image.bottom+10, KScreenWidth-80, 20)];

 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
 
    NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
_label.text = [NSString stringWithFormat:@"嘉兴港区管委会移动平台 :v%@",appVersion];
_label.textAlignment = NSTextAlignmentCenter;
_label.font = [UIFont systemFontOfSize:16];
[self.view addSubview:_label];
 NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute fromDate:[NSDate date]];
  
   NSString *yearstring = [NSString stringWithFormat:@"%ld",(long)[components year]];
_label1 = [[UILabel alloc]initWithFrame:CGRectMake((kScreenWidth-300)/2, KScreenHeight-60, 300, 20)];
_label1.textAlignment = NSTextAlignmentCenter;
_label1.font = [UIFont systemFontOfSize:12];
_label1.text = [NSString stringWithFormat:@"Copyright©%@嘉兴港区管委会",yearstring];
_label1.textColor = [UIColor colorWithHexString:@"aeaeae"];
[self.view addSubview:_label1];
_label2 = [[UILabel alloc]initWithFrame:CGRectMake((kScreenWidth-300)/2, _label1.bottom+10, 300, 20)];
_label2.textAlignment = NSTextAlignmentCenter;
_label2.font = [UIFont systemFontOfSize:12];
_label2.text = @"技术支持:杭州飞软软件有限公司";
_label2.textColor = [UIColor colorWithHexString:@"aeaeae"];
[self.view addSubview:_label2];
_view3 = [[UITableView alloc]initWithFrame:CGRectMake(0, _label.bottom+50, KScreenWidth, 100) style:UITableViewStylePlain];
_view3.dataSource = self;
 _view3.separatorColor = [UIColor colorWithHexString:@"f5f5f5"];
_view3.backgroundColor = [UIColor whiteColor];
_view3.delegate = self;
self.view3.bounces = NO;
//_view3.separatorStyle = NO;
  self.view3.scrollEnabled =NO;
[self.view addSubview:_view3];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

if (indexPath.row ==0) {
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
       cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //显示最右边的箭头

//     cell.backgroundColor = [UIColor clearColor];
    
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 200, cell.contentView.height)];
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
    label.text = @"欢迎页";
    label.textColor = [UIColor colorWithHexString:@"484848"];
     label.font = [UIFont systemFontOfSize:16];
    [cell.contentView addSubview:label];
    
    return cell;

}if (indexPath.row ==1){
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
       cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //显示最右边的箭头

//     cell.backgroundColor = [UIColor clearColor];
    
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 200, cell.contentView.height)];
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
    label.text = @"版权信息";
    label.textColor = [UIColor colorWithHexString:@"484848"];
     label.font = [UIFont systemFontOfSize:16];
    [cell.contentView addSubview:label];
    
    return cell;

}else{
    
     UITableViewCell* cell = [[UITableViewCell alloc]init];
       cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //显示最右边的箭头

//     cell.backgroundColor = [UIColor clearColor];
    
      UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 200, cell.contentView.height)];
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
    label.text = @"联系我们";
    label.textColor = [UIColor colorWithHexString:@"484848"];
     label.font = [UIFont systemFontOfSize:16];
    [cell.contentView addSubview:label];
    
    return cell;

}







}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 1) {
    NSArray *title = @[ @"承办单位:嘉兴港区管委会" , @"技术支持:杭州飞软软件公司"];

 CWActionSheet *sheet = [[CWActionSheet alloc] initWithTitles:title :@"关闭" clickAction:^(CWActionSheet *sheet, NSIndexPath *indexPath) {
//        self.label.text = title[indexPath.row];

}];
    [sheet show];
}
if (indexPath.row == 2) {
    NSArray *title = @[@"技术支持", @"钉钉交流群:21701583" ];

 CWActionSheet *sheet = [[CWActionSheet alloc] initWithTitles:title :@"取消" clickAction:^(CWActionSheet *sheet, NSIndexPath *indexPath) {
 
 if(indexPath.row ==0 ){
// NSString *url0 = @"0";
//     NSString *url = [NSString stringWithFormat:@"dingtalk://dingtalkclient/page/link?url=%@",[url0 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
 
//   if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:url]]) {
//21701583
     [ gyViewController openDingTalkUrl:@"https://www.baidu.com"];

//    }else{
//[self.view makeToast:@"请安装钉钉"];
//
//    }

 
 }

}];
    [sheet show];
}
if (indexPath.row == 0) {

    //创建引导页视图
    ZLCGuidePageView *pageView = [[ZLCGuidePageView alloc]initWithFrame:self.view.frame WithImages:_images];
    [self.view.window addSubview:pageView];
}

}
+(BOOL)openDingTalkUrl:(NSString*) targetUrl{
    if (targetUrl.length == 0) {
        return false;
    }
//    NSString* string2 = [string1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


//    NSString *url = [NSString stringWithFormat:@"dingtalk://dingtalkclient/page/link?url=%@",
//                     [targetUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    
//    NSString *url = [NSString stringWithFormat:@"dingtalk://dingtalkclient/page/link?url="];
        NSString *url = [NSString stringWithFormat:@"https://qr.dingtalk.com/action/sendmsg?dingtalk_id=yeyanming1"];

//https://qr.dingtalk.com/action/sendmsg?dingtalk_id=yeyanming1

    return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
